import pandas as pd
import numpy as np
from random import random

# df = pd.DataFrame({'angles': [0, 3, 4],
#                    'degrees': [360, 180, 360]},
#                   index=['circle', 'triangle', 'rectangle'])
# print(df)
batch_size = 300

feature_count = 10

data = []
for index, i in enumerate(range(batch_size)):
    data.append([round(random(), 2) for _ in range(10)])
data_matrix = np.asarray(data)

print(data_matrix.shape)
scale = 1 << 10
partner_f_count = data_matrix.shape
partner_matrix = data_matrix
a, b, c, r = 1, 2, 4, 0
a = a * np.ones(partner_f_count)
b = b * np.ones(partner_f_count)
c = c * np.ones(partner_f_count)
r = r * np.ones(partner_f_count)

y1 = partner_matrix * scale - r
x1 = r
v1 = (y1 + b)
u1 = (x1 + a)



if __name__ == '__main__':
    from promoter import u0, v0, lm, delta_y

    print("promoter", "-" * 22)
    print(lm)   #y
    print(u0)   #lm+1
    print(v0)      #2
    print("provider", "-" * 22)
    print(partner_matrix)
    print(u1)   #1
    print(v1)   #partner_matrix*1024+2
    print("-" * 22)

    u = (u0 + u1)  #lm+2  y*1024 + 2
    v = (v0 + v1)   #partner_matrix*1024+4
    # a, b, c, r = 1, 2, 4, 0
    # u * v - 2* b * u - 2* a * v + 2*c
    # [y*1024 + 2][partner_matrix*1024+4] - 4[y*1024 + 2] - 2[partner_matrix*1024+4] + 8
    print("promoter,fed_matrix", "-" * 22)
    fed_matrix_1 = -b * u - a * v + c
    print(fed_matrix_1)
    print(fed_matrix_1.shape)
    fed_sum_1 = np.sum(fed_matrix_1, axis=0)
    print(fed_sum_1)
    print(fed_sum_1.shape)

    print("provider,fed_matrix", "-" * 22)
    fed_matrix_2 = u * v - b * u - a * v + c
    print(fed_matrix_2)
    print(fed_matrix_2.shape)
    fed_sum_2 = np.sum(fed_matrix_2, axis=0)
    print(fed_sum_2)
    print(fed_sum_2.shape)

    fed_matrix_3 = fed_matrix_2+fed_matrix_1
    print(fed_matrix_3)
    fed_sum_3 = np.sum(fed_matrix_3, axis=0)
    print(fed_sum_3)

    z = fed_sum_1+fed_sum_2
    print(delta_y)
    print(z/(1024*1024))
    print(z.shape)

    g_B = np.zeros(feature_count)
    for idx, row in enumerate(data_matrix):
        g_B += delta_y[idx] * row
    print(g_B)
